using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections.Specialized;

namespace Axe.Logging
{
    public class LogFilter : ILogger, IDisposable
    {
        ILogger m_FilteredLog;
        LogEntryType m_FilterRules;

        public LogFilter(ILogger filteredLog, LogEntryType filterRules)
        {
            m_FilteredLog = filteredLog;
            m_FilterRules = filterRules;
        }

        #region ILogger Members

        public void Add(LogEntry entry)
        {
            if ((entry.EventType & m_FilterRules) == entry.EventType)
            {
                m_FilteredLog.Add(entry);
            }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if(m_FilteredLog is IDisposable)
            {
                (m_FilteredLog as IDisposable).Dispose();
            }
        }

        #endregion

        #region ILogger Members

        public bool Initialize(NameValueCollection e)
        {
            return true;
        }

        #endregion
    }
}
